home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MultiSession 1.04 Source / Core 27⁄June⁄1993 / CSaveBeforeClosing.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-04  |  3.2 KB  |  107 lines  |  [TEXT/KAHL]

  1. /* CSaveBeforeClosing.c */
  2.  
  3. #include "CSaveBeforeClosing.h"
  4. #include "CImagePane.h"
  5. #include "CStaticText.h"
  6. #include "Memory.h"
  7. #include "StringUtils.h"
  8.  
  9.  
  10. #define SaveBeforeClosingWindowLocID (140L*65536L + 1)
  11. #define YesSaveButtonLocID (140L*65536L + 2)
  12. #define NoSaveButtonLocID (140L*65536L + 3)
  13. #define CancelButtonLocID (140L*65536L + 4)
  14. #define SaveBeforeClosingTextLoc (140L*65536L + 5)
  15. #define SaveBeforeClosingPictID (136)
  16. #define PictLocID (130L*65536L + SaveBeforeClosingPictID)
  17.  
  18. #define YesSaveButtonTextID (140L*65536L + 2)
  19. #define NoSaveButtonTextID (140L*65536L + 3)
  20. #define CancelButtonTextID (140L*65536L + 4)
  21. #define SaveBeforeClosingTextID (140L*65536L + 5)
  22.  
  23.  
  24. short            CSaveBeforeClosingWindow::SaveBeforeClosing(PString Name)
  25.     {
  26.         CAskButton*        Button;
  27.         CStaticText*    Text;
  28.         CImagePane*        PaneInTheButt;
  29.         MyBoolean            YesSave;
  30.         MyBoolean            NoSave;
  31.         MyBoolean            Cancelled;
  32.         LongPoint            Start;
  33.         LongPoint            Extent;
  34.         Handle                Temp1;
  35.         Handle                Temp2;
  36.         Handle                Temp3;
  37.  
  38.         APRINT(("+CSaveBeforeClosingWindow::SaveBeforeClosing"));
  39.         GetRect(SaveBeforeClosingWindowLocID,&Start,&Extent);
  40.         IModalDialog(CenterRect(Extent,MainScreenSize()),Extent,DontAllowMenus);
  41.  
  42.         GetRect(SaveBeforeClosingTextLoc,&Start,&Extent);
  43.         Text = new CStaticText;
  44.         BeginStringOperation();
  45.         Temp1 = GetCString(SaveBeforeClosingTextID);
  46.         RegisterString(Temp1);
  47.         Temp2 = PString2Handle(Name);
  48.         RegisterString(Temp2);
  49.         Temp3 = PString2Handle("\p_");
  50.         RegisterString(Temp3);
  51.         Temp1 = ReplaceStr(Temp1,Temp3,Temp2);
  52.         EndStringOperation(Temp1);
  53.         Text->IStaticText(Start,Extent,Temp1,systemFont,12,this,this,JustifyLeft);
  54.  
  55.         GetRect(PictLocID,&Start,&Extent);
  56.         PaneInTheButt = new CImagePane;
  57.         PaneInTheButt->IImagePane(Start,Extent,this,this,SaveBeforeClosingPictID);
  58.  
  59.         GetRect(YesSaveButtonLocID,&Start,&Extent);
  60.         Button = new CAskButton;
  61.         Button->IAskButton(Start,Extent,GetCString(YesSaveButtonTextID),0x0d,0,
  62.             this,this,&YesSave);
  63.  
  64.         GetRect(NoSaveButtonLocID,&Start,&Extent);
  65.         Button = new CAskButton;
  66.         Button->IAskButton(Start,Extent,GetCString(NoSaveButtonTextID),0,0,
  67.             this,this,&NoSave);
  68.  
  69.         GetRect(CancelButtonLocID,&Start,&Extent);
  70.         Button = new CAskButton;
  71.         Button->IAskButton(Start,Extent,GetCString(CancelButtonTextID),'.',cmdKey,
  72.             this,this,&Cancelled);
  73.  
  74.         YesSave = False;
  75.         NoSave = False;
  76.         Cancelled = False;
  77.         DoEventLoop();
  78.         APRINT(("-CSaveBeforeClosingWindow::SaveBeforeClosing"));
  79.         if (YesSave) {return Yes_Save;}
  80.         if (NoSave) {return No_Save;}
  81.         if (Cancelled) {return Cancel_Close;}
  82.         EXECUTE(PRERR(AllowResume,"CSaveBeforeClosingWindow::SaveBeforeClosing "
  83.             "Received no result from it's buttons."));
  84.         EXECUTE(return Cancel_Close);
  85.     }
  86.  
  87.  
  88. void            CAskButton::IAskButton(LongPoint Start, LongPoint Extent, Handle NameString,
  89.                         char Key, short Modifiers, CWindow* TheWindow, CEnclosure* TheEnclosure,
  90.                         MyBoolean* TheAnswerLoc)
  91.     {
  92.         APRINT(("+CAskButton::IAskButton"));
  93.         AnswerLoc = TheAnswerLoc;
  94.         ISimpleButton(Start,Extent,NameString,Key,Modifiers,TheWindow,TheEnclosure);
  95.         APRINT(("-CAskButton::IAskButton"));
  96.     }
  97.  
  98.  
  99. MyBoolean    CAskButton::DoThang(void)
  100.     {
  101.         APRINT(("+CAskButton::DoThang"));
  102.         (*AnswerLoc) = True; /* export result */
  103.         delete Window; /* make window go away */
  104.         APRINT(("-CAskButton::DoThang"));
  105.         return True;
  106.     }
  107.